//package org.tabularium.text.se;
//
//import java.io.IOException;
//import java.util.logging.Logger;
//
//import org.apache.lucene.analysis.Analyzer;
//import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
//import org.apache.lucene.analysis.SimpleAnalyzer;
//import org.apache.lucene.document.Document;
//import org.apache.lucene.document.Field;
//import org.apache.lucene.index.IndexReader;
//import org.apache.lucene.index.IndexWriter;
//import org.tabularium.text.TermWeightVector;
//
//public class LuceneTermWeightVectorStorer implements TermWeightVectorStorer {
//
//	protected String dir;
//	protected Analyzer analyzer;
//	protected IndexWriter writer = null;
//	protected PerFieldAnalyzerWrapper fieldAnalyzer;
//	protected Logger logger = Logger
//			.getLogger("org.tabularium.text.se.LuceneTermWeightVectorStorer");
//
//	public LuceneTermWeightVectorStorer(String dir) throws IOException {
//		this.dir = dir;
//		// creates analyzer instances
//		this.analyzer = new SimpleAnalyzer();
//		fieldAnalyzer = new PerFieldAnalyzerWrapper(analyzer);
//		fieldAnalyzer.addAnalyzer("idstorer", new UrlFieldAnalyzer());
//
//		if (!IndexReader.indexExists(dir)) {
//			clear();
//		}
//	}
//	
//	public void clear() throws IOException {
//		// TODO Auto-generated method stub
//		
//	}
//
//	public TermWeightVector[] retrieve(String id) throws IOException {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	public int size() throws IOException {
//		// TODO Auto-generated method stub
//		return 0;
//	}
//
//	public void store(String id, TermWeightVector v) throws IOException {
//		Document lucenedoc = new Document();
//		// not tokenized but indexed
//		if (id != null) {
//			lucenedoc.add(new Field("idstorer", escapeQuotes(id), true, true,
//					false));
//		}
//		// only stored, not indexed nor tokenized
//		if (obj != null) {
//			lucenedoc
//					.add(new Field("body", new String(obj), true, false, false));
//		}
//		if (res != null) {
//			lucenedoc.add(new Field("resource", res, true, false, false));
//		}
//		lucenedoc.add(new Field("timestamp", Long.toString(System
//				.currentTimeMillis()), true, false, false));
//
//		// no one must delete while new docs are inserted
//		synchronized (this) {
//			writer = new IndexWriter(dir, fieldAnalyzer, false);
//			writer.addDocument(lucenedoc);
//			writer.close();
//		}
//	}
//
//	public static String escapeQuotes(String s) {
//		return s.replaceAll("\"", "%22");
//	}
//}
